<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>   
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>  
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>  
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>       
<c:set var="ctx" value="${pageContext.request.contextPath}"/> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<jsp:include page="../include.jsp"/>
<script type="text/javascript">
	
	$(function() {
		parent.$.messager.progress('close');
		$('#form').form({
			url : '${ctx}/module/addModule',
			onSubmit : function() {
				validate = $(this).form('validate');					
				if(validate){
					return true;
				}else{
					return false;
				}				
			},
			success : function(result) {
				parent.$.messager.progress('close');
				result = $.parseJSON(result);
				if(result.success) {
					parent.$.modalDialog.openner_dataGrid.treegrid('load');
					parent.$.modalDialog.handler.dialog('close');
					parent.$.messager.alert('系统提示', result.msg, 'info');
				} else {
					parent.$.messager.alert('错误', result.msg, 'error');
				}
			}
		});
		
		$('#cc').combotree({    
		    url: '${ctx}/module/getAllResources',    
		    required: true,
		    lines:true
		}); 
		var id = "${id}";
		if(id !=""){
			$('#cc').combotree('setValue', id);
		}
	});
	

</script>
</head>
<body>
	<div class="easyui-layout" data-options="fit:true,border:false">
		<div data-options="region:'center',border:false" title="" style="overflow: hidden;">			
			<form id="form" method="post">
				<input name="moduleId" type="hidden" value="${moduleId}">	
				<div style="margin-bottom:5px;padding-top:30px;padding-left:40px">
	                <input labelAlign="right" id="cc" name="parentId" value="${module.parentId}" style="width:80%" data-options="label:'父节点:',required:true">
	            </div>
	            <div style="margin-bottom:5px;padding-left:40px">
	                <input labelAlign="right" class="easyui-textbox" name="moduleName" value="${module.moduleName}" style="width:80%" data-options="label:'配置名称:',required:true">
	            </div>
	            <div style="margin-bottom:5px;padding-left:40px">
	                <input labelAlign="right" id="moduleCode" class="easyui-textbox" name="moduleCode" value="${module.moduleCode}" style="width:80%" data-options="label:'配置编码:'" >	               
	            </div>	
		        <div style="margin-bottom:5px;padding-left:40px">
		          <label style="text-align: right"  class="textbox-label textbox-label-after textbox-label-checked">资源类型:</label>                        
		          <c:if test="${empty moduleId}">
		          	<input class="easyui-radiobutton" name="moduleType" value="1" label="url链接" labelWidth="70px" labelPosition="after" >
		          	<input class="easyui-radiobutton" name="moduleType" value="2" label="按钮权限码" labelWidth="90px" labelPosition="after" checked="true">
		          	<input class="easyui-radiobutton" name="moduleType" value="3" label="标签 accordion" labelWidth="120px" labelPosition="after">
		          	<input class="easyui-radiobutton" name="moduleType" value="4" label="其他" labelWidth="60px"labelPosition="after">
		          </c:if>
		          <c:if test="${not empty moduleId}">
		          	<input class="easyui-radiobutton" name="moduleType" value="1" label="url链接" labelWidth="70px" labelPosition="after" <c:if test="${module.moduleType=='1'}">checked="true"</c:if> >
		          	<input class="easyui-radiobutton" name="moduleType" value="2" label="按钮权限码" labelWidth="90px" labelPosition="after" <c:if test="${module.moduleType=='2'}">checked="true"</c:if>>
		          	<input class="easyui-radiobutton" name="moduleType" value="3" label="标签 accordion" labelWidth="120px" labelPosition="after" <c:if test="${module.moduleType=='3'}">checked="true"</c:if>>
		         	<input class="easyui-radiobutton" name="moduleType" value="4" label="其他" labelWidth="60px"labelPosition="after" <c:if test="${module.moduleType=='4'}">checked="true"</c:if>>
		          </c:if>
		        </div>          
	            <div style="margin-bottom:5px;padding-left:40px">
	                <input labelAlign="right" class="easyui-textbox" name="url" value="${module.url}" style="width:80%" data-options="label:'url:'">
	            </div>
	            <c:if test="${not empty moduleId}">
	            	<div style="margin-bottom:5px;padding-left:40px">
		                <input labelAlign="right" class="easyui-textbox" name="sort" value="${module.sort}" style="width:30%" data-options="label:'排序:'">&nbsp;<font color="red">(值越小越靠前)</font>
		            </div>
		            <div style="margin-bottom:5px;padding-left:40px">
		                <input labelAlign="right" class="easyui-textbox" name="iconCls" value="${module.iconCls}" style="width:30%" data-options="label:'图标:'">
		            </div>
	            </c:if>
	            <c:if test="${empty moduleId}">
	            	<div style="margin-bottom:5px;padding-left:40px">
		                <input labelAlign="right" class="easyui-textbox" name="sort" value="1" style="width:30%" data-options="label:'排序:'">&nbsp;<font color="red">(值越小越靠前)</font>
		            </div>
		            <div style="margin-bottom:5px;padding-left:40px">
		            	<input labelAlign="right" class="easyui-textbox" name="iconCls" value="${module.iconCls}" style="width:30%" data-options="label:'图标:'">
		            </div>
	            </c:if>
	             <div style="margin-bottom:5px;padding-left:40px">
	           	  	  <label style="text-align:right"  class="textbox-label textbox-label-after textbox-label-checked">启用状态:</label>
	            	  <c:if test="${empty moduleId}">
			          	<input class="easyui-radiobutton" name="activate" value="1" label="启用" labelWidth="40px" labelPosition="after" checked="true">
			          	<input class="easyui-radiobutton" name="activate" value="0" label="停用" labelWidth="40px" labelPosition="after">		          	
			          </c:if>
			          <c:if test="${not empty moduleId}">
			          	<input class="easyui-radiobutton" name="activate" value="1" label="启用" labelWidth="40px" labelPosition="after" <c:if test="${module.activate=='1'}">checked="true"</c:if> >
			          	<input class="easyui-radiobutton" name="activate" value="0" label="停用" labelWidth="40px" labelPosition="after" <c:if test="${module.activate=='0'}">checked="true"</c:if>>		          	
			          </c:if>
			     </div>
	            <div style="margin-bottom:5px;padding-left:40px">
	                <input labelAlign="right" class="easyui-textbox" name="configDescr" style="width:80%;height:60px" data-options="label:'配置描述:',multiline:true">
	            </div>	           
	        </form>
		</div>
	</div>
</body>
</html>